package cn.bnuz.edu.todolist;

import android.annotation.SuppressLint;
import android.content.ContentValues;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {
    private final int[] categoriesTextView = {
        R.id.category_1, R.id.category_2, R.id.category_3
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        for (int id: categoriesTextView) {
            TextView currentCategory = (TextView)findViewById(id);
            currentCategory.setClickable(true);
            currentCategory.setFocusable(true);
            currentCategory.setOnClickListener(l);
        }

        Button button_add = findViewById(R.id.button_add);
        button_add.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this,AddTodoList.class);
                startActivity(intent);
            }
        });


    }

    View.OnClickListener l = new View.OnClickListener() {
        @SuppressLint("NonConstantResourceId")
        @Override
        public void onClick(View v) {
            Intent intent = null;
            intent = new Intent(MainActivity.this, TodoListTodayActivity.class);
            switch (v.getId()) {
                case R.id.category_1:
                    intent = new Intent(MainActivity.this, TodoListTodayActivity.class);
                    break;
                case R.id.category_2:
                    intent = new Intent(MainActivity.this, TodoListPlanActivity.class);
                    break;
                case R.id.category_3:
                    intent = new Intent(MainActivity.this, TodoListAllActivity.class);
                    break;
            }
            startActivityForResult(intent, 1);
        }
    };
}